function apiIntercepter(req, res, next) {
  // get, post 参数统一获取
  req.getParams = function () {
    return { ...req.query, ...req.body, ...req.params };
  };

  res.ok = function (data) {
    res.json({ code: 200, message: "操作成功", data: data });
  };

  res.error = function (message, code = 0) {
    res.json({ code: code, message });
  };

  next();
}

module.exports = {
  apiIntercepter,
};
